#include<bits/stdc++.h>
using namespace std;
int t,n,a[200009],f[200009],ans,c[200009],sum;
void dfs(int s){
    if(s>n)return;
    f[s]=1;
    dfs(s+1);
    for(int i=1;i<=n;++i){
        for(int j=i-1;j>=1;--j){
            if(f[i]==f[j]){
                if(a[i]==a[j])c[i]=a[i];
                break;
            }
        }
    }
    sum=0;
    for(int i=1;i<=n;++i)sum+=c[i];
    ans=max(ans,sum);
    f[s]=0;
    dfs(s+1);
    for(int i=1;i<=n;++i){
        for(int j=i-1;j>=1;--j){
            if(f[i]==f[j]){
                if(a[i]==a[j])c[i]=a[i];
                break;
            }
        }
    }
    sum=0;
    for(int i=1;i<=n;++i)sum+=c[i];
    ans=max(ans,sum);
}
int main(){
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    cin>>t;
    for(int ii=1;ii<=t;++ii){
        ans=0;
        scanf("%d",&n);
        for(int i=1;i<=n;++i){
            scanf("%d",&a[i]);
        }
        dfs(1);
        printf("%d\n",ans);
        for(int i=1;i<=209;++i){f[i]=0,a[i]=0,c[i]=0;}
    }
}
